package week10;

import java.text.NumberFormat;

public class DVD {
    private String title, director;
    private int year;
    private double cost;
    private boolean bluray;

    public DVD(String title, String director, int year, double cost, boolean bluray){
        this.title = title;
        this.director = director;
        this.year = year;
        this.cost = cost;
        this.bluray = bluray;
    }

    @Override
    public String toString() {
        NumberFormat fmt = NumberFormat.getCurrencyInstance();
        String description;

        description = fmt.format(cost) + "\t" + year + "\t";
        description += title + "\t" + director;
        if (bluray)
        {description += "\t" + "Blu-ray";}
        return description;
    }

    public int compareTo(DVD mag) {
        int i = 0;
        int a = 0;
        while (title.charAt(i) == mag.toString().charAt(i)) {
            i++;
        }
        if ((int) (title.charAt(i)) < (int) (mag.toString().charAt(i)))
        {a = -1;}
        else
        {a = 1;}
        return a;
    }
}
